package com.yvon.boot.common.result;

/**
 * 常用API操作码
 *
 * @author yvon
 * @date 2020-06-08
 */
public enum ResultCode implements IErrorCode {

    // 200- 成功响应
    SUCCESS(200, "操作成功"),

    // 3000- 校验类异常
    ILLEGAL_ARGUMENT(3000, "参数违法"),
    TYPE_ARGUMENT(3001, "数据类型异常"),
    INVALID_PARAMETER(3002, "请求参数不符合条件，请核实后重试！"),
    VALIDATE_FAILED(3003, "参数校验失败"),
    MAX_UPLOAD_SIZE_EXCEEDED(3004, "文件大小超出最大限制"),
    REQUEST_METHOD_NOT_SUPPORTED(3005, "请求方法不支持访问方式"),
    MEDIA_TYPE_NOT_SUPPORTED(3006, "请求类型不匹配"),
    PARAM_EX(3007, "参数类型解析异常"),

    // 4000- 权限相关异常
    UNAUTHORIZED(4001, "暂未登录或token已过期"),
    TOKEN_NOT_FIND(4002, "token不能为空"),
    FORBIDDEN(4003, "权限不足"),
    JWT_USER_INVALID(4004, "用户名或密码错误"),
    JWT_USER_NOT_FOUND(4006, "用户不存在"),
    JWT_USER_ENABLED(4007, "用户已经被禁用！"),
    LDAP_USER_NOT_FOUND(4008, "Ldap用户不存在"),

    // 5000- 代码层面异常
    FAILED(5000, "操作失败"),
    DUPLICATE_PRIMARY_KEY(5100,"唯一键冲突"),

    // -1 系统相关异常
    GLOBAL_EXCEPTION(-1, "系统出现错误，请稍后重试！"),
    BUSY(-2, "系统繁忙，请稍后重试！"),
    TIMEOUT(-3, "系统超时，请稍后重试！"),
    RUNTIME_EXCEPTION(-4, "运行时出现异常，请稍后重试！"),


    /**
     * 客户端
     */
    CLIENT_BAD_PARAMETERS(6001, "客户端参数错误"),
    TEMPLATE_NOT_FOUND(6002, "找不到模板或模板已被删除"),

    /**
     * 系统
     */
    SERVICE_ERROR(7001, "服务执行异常"),
    RESOURCE_NOT_FOUND(7404, "资源不存在"),


    /**
     * pipeline
     */
    CONTEXT_IS_NULL(8001,"流程上下文为空"),
    BUSINESS_CODE_IS_NULL(8002,"业务代码为空"),
    PROCESS_TEMPLATE_IS_NULL(8003,"流程模板配置为空"),
    PROCESS_LIST_IS_NULL(8004,"业务处理器配置为空" ),


    CLIENT_AUTHENTICATION_FAILED(4001,"客户端认证失败"),
    USERNAME_OR_PASSWORD_ERROR(4002,"用户名或密码错误"),
    UNSUPPORTED_GRANT_TYPE(4003, "不支持的认证模式");

    private Integer code;
    private String message;

    private ResultCode(Integer code, String message){
        this.code = code;
        this.message = message;
    }

    @Override
    public Integer getCode() {
        return code;
    }

    @Override
    public String getMessage() {
        return message;
    }
}
